Skip to content

fix(strategy): expose --spectral-alpha for the decaying-spectrum fill#232

Merged
zeokin merged 3 commits into
zeokin:mainfrom
ultrahighsuper:feat/strategy-cli-spectral-alpha
Jul 16, 2026
Merged

fix(strategy): expose --spectral-alpha for the decaying-spectrum fill#232
zeokin merged 3 commits into
zeokin:mainfrom
ultrahighsuper:feat/strategy-cli-spectral-alpha

Conversation

@ultrahighsuper

Copy link
Copy Markdown
Contributor

PR kind

  • fix
  • feat

Summary

storage.generate takes a spectral_alpha knob (the k^-alpha singular-value decay for --fill decaying-spectrum), but the strategy CLI had no flag for it and runner.run/runner.compare didn't thread it through — so every decaying-spectrum run was hardcoded to alpha=1.0. It was the only generate() parameter with no CLI path. Now that decaying-spectrum is a scored track (floor 0.90), contributors need to sweep the decay rate to see where a transform holds up vs. degrades.

This adds --spectral-alpha (float, default 1.0, >= 0; negatives grow the tail — not a decaying spectrum — and are rejected at the CLI boundary like --n/--data-rank) and threads it through runner.run/compare into storage.generate.

Fixes #231. Distinct from #229 (which only corrects the --data-rank help text).

Effect (GPU end-to-end, N=512, decaying-spectrum, M=48)

--spectral-alpha 0.5 -> rel_err 7.0e-01   (gentle decay: hard)
--spectral-alpha 3.0 -> rel_err 4.1e-03   (steep decay: compressible)

Steeper alpha packs more energy into the leading components, so the subspace method reconstructs it far better — exactly the axis this fill is meant to probe.

Validation (CPU-safe path)

$ python -m pytest tests/ strategy/tests/ eval/tests/ -q
314 passed, 2 failed

The 2 failures pre-exist on clean main and are environment-only (Windows path-separator assertion in eval/tests/test_gpu_batch.py; fp16 in-core/tiled parity on a GTX 1650). New tests: negative --spectral-alpha exits cleanly (rc 2), the flag is parsed with default 1.0, and a larger alpha provably steepens the singular-value decay (pure NumPy).

Scope

  • strategy/cli.py + strategy/runner.py + tests only; open (non-protected) zone. Pure plumbing of an existing-but-unreachable knob; no behavior change at the default alpha=1.0.

storage.generate takes a spectral_alpha knob (the k^-alpha singular-value decay
for --fill decaying-spectrum), but the strategy CLI had no flag for it and
runner.run/compare didn't thread it through, so every decaying-spectrum run was
hardcoded to alpha=1.0 -- the only generate() parameter with no CLI path. Now
that decaying-spectrum is a scored track (floor 0.90), contributors need to
sweep the decay rate to see where a transform holds vs. degrades.

Add --spectral-alpha (float, default 1.0, >= 0; negatives grow the tail and are
rejected at the CLI boundary like --n/--data-rank) and thread it through
runner.run/compare into storage.generate. End-to-end (N=512, M=48):
--spectral-alpha 0.5 -> rel_err 0.70; 3.0 -> rel_err 0.004.

Adds CLI-validation and pure-NumPy plumbing/effect tests.

Fixes zeokin#231
@github-actions github-actions Bot added area:strategy Smart strategies / transforms (strategy/) area:tests Correctness gates and test suites (tests/) status:needs-review Awaiting maintainer review type:bug Something is incorrect or broken status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only labels Jul 14, 2026
@zeokin

zeokin commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Thanks @ultrahighsuper — this is a real fix and CI is green, but it now conflicts with strategy/cli.py after #224 (--rank-m validation), #229 (--data-rank help), and #228 (--compare --quiet) landed on main. Per our workflow I don't rebase contributor branches myself. Please rebase onto the latest main and re-apply the --spectral-alpha argument/validation/forwarding around the now-present changes, then push — it'll merge once green. (Note: #233 is an identical duplicate of this PR and is being closed in favor of this one.)

# Conflicts:
#	strategy/cli.py
#	tests/test_cli_errors.py
@github-actions

Copy link
Copy Markdown
Contributor

This PR currently has merge conflicts with the base branch. Please resolve them within 12 hours or the bot will close the PR automatically.

@github-actions github-actions Bot added status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only and removed status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only labels Jul 14, 2026

@zeokin zeokin left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes before merge.

  1. Rebase onto current main; strategy/cli.py and tests/test_cli_errors.py changed in the merged fix batch.
  2. Reject non-finite --spectral-alpha values. The current args.spectral_alpha < 0 guard lets NaN and +inf through; use a finite-value check and add regression cases for NaN, +inf, and -inf that exit cleanly before backend/matrix work.

The CLI plumbing is otherwise useful, but this public numeric input must not be able to poison decaying-spectrum generation.

@github-actions github-actions Bot added status:changes-requested Maintainer requested changes; new commit required within the review window and removed status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only labels Jul 15, 2026
@github-actions github-actions Bot added status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only and removed status:changes-requested Maintainer requested changes; new commit required within the review window labels Jul 15, 2026
@zeokin
zeokin merged commit 04071ca into zeokin:main Jul 16, 2026
6 checks passed
zeokin added a commit that referenced this pull request Jul 16, 2026
zeokin added a commit that referenced this pull request Jul 16, 2026
Re-applies the changes from #235, #253, #255, #266, #267, and #268, which
were reverted in error on 2026-07-16. #232 was already restored in 4c44b45.

CPU-safe suite green (411 passed, 24 skipped).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:strategy Smart strategies / transforms (strategy/) area:tests Correctness gates and test suites (tests/) status:needs-review Awaiting maintainer review status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only type:bug Something is incorrect or broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] strategy CLI offers --fill decaying-spectrum but no way to set its k^-alpha decay rate (stuck at alpha=1.0)

2 participants